<template>
	<view class="home-container">
		<!-- 自定义导航栏 -->
		<custom-navbar title="商家主页" :show-back="false">
			
		</custom-navbar>
		
		<!-- 头部区域 -->
		<view class="header">
			<view class="header-content">
				<view class="user-info" @click="goToEditProfile">
					<view class="avatar">
						<image src="/static/图层 3.png" mode="aspectFill" class="avatar-img"></image>
					</view>
					<view class="user-details">
						<view class="shop-name">大美汽修厂,欢迎您</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 核销操作区 -->
		<view class="verification-section">
			<view class="verification-buttons">
				<view class="verification-btn" @click="goToScan">
					<image src="/static/扫码.png" mode="aspectFit" class="btn-icon"></image>
					<text class="btn-text">扫码核销</text>
				</view>
				<view class="verification-divider"></view>
				<view class="verification-btn" @click="goToInput">
					<image src="/static/输入2.png" mode="aspectFit" class="btn-icon"></image>
					<text class="btn-text">输入核销码</text>
				</view>
			</view>
		</view>
		
		<!-- 功能菜单网格 -->
		<view class="menu-section">
			<view class="menu-grid">
				<!-- 第一行 -->
				<view class="menu-item" @click="goToStatistics">
					<view class="menu-icon blue">
						<image src="/static/统计.png" mode="aspectFit" class="icon-img"></image>
					</view>
					<text class="menu-text">经营统计</text>
				</view>
				
				<view class="menu-item" @click="goToRecords">
					<view class="menu-icon orange">
						<image src="/static/核销记录 (1).png" mode="aspectFit" class="icon-img"></image>
					</view>
					<text class="menu-text">核销记录</text>
				</view>
				
				<view class="menu-item" @click="goToFinance">
					<view class="menu-icon light-blue">
						<image src="/static/123收支明细.png" mode="aspectFit" class="icon-img"></image>
					</view>
					<text class="menu-text">收支明细</text>
				</view>
				
				<view class="menu-item" @click="goToOrders">
					<view class="menu-icon yellow">
						<image src="/static/订单管理.png" mode="aspectFit" class="icon-img"></image>
						<view class="badge">12</view>
					</view>
					<text class="menu-text">订单管理</text>
				</view>
				
				<!-- 第二行 -->
				<view class="menu-item" @click="goToCoupons">
					<view class="menu-icon light-blue">
						<image src="/static/卡券.png" mode="aspectFit" class="icon-img"></image>
					</view>
					<text class="menu-text">卡券管理</text>
				</view>
				
				<view class="menu-item" @click="goToTasks">
					<view class="menu-icon teal">
						<image src="/static/维修.png" mode="aspectFit" class="icon-img"></image>
						<view class="badge">17</view>
					</view>
					<text class="menu-text">维修任务</text>
				</view>
				
				<view class="menu-item" @click="goToReviews">
					<view class="menu-icon red">
						<image src="/static/评价管理.png" mode="aspectFit" class="icon-img"></image>
					</view>
					<text class="menu-text">评价管理</text>
				</view>
				
				<view class="menu-item" @click="goToProfile">
					<view class="menu-icon blue">
						<image src="/static/资料库.png" mode="aspectFit" class="icon-img"></image>
					</view>
					<text class="menu-text">商户资料</text>
				</view>
				
				<!-- 第三行 -->
				<view class="menu-item" @click="goToActivities">
					<view class="menu-icon orange">
						<image src="/static/活动.png" mode="aspectFit" class="icon-img"></image>
					</view>
					<text class="menu-text">活动发布</text>
				</view>
				<view class="menu-item" @click="goToRescue">
					<view class="menu-icon red">
						<image src="/static/应急救援.png" mode="aspectFit" class="icon-img"></image>
					</view>
					<text class="menu-text">应急救援</text>
				</view>
			</view>
		</view>
		
		<!-- 最新通知区 -->
		<view class="notification-section">
			<view class="notification-header">
				<view class="header-left">
					<image src="/static/消息-信息.png" mode="aspectFit" class="header-icon"></image>
					<text class="header-title">最新通知</text>
				</view>
				<view class="header-right" @click="goToTasks">
					<text class="header-link">今日需上门取车任务共32单 ></text>
				</view>
			</view>
			
			<view class="notification-table">
				<view class="table-header">
					<text class="header-cell">用户</text>
					<text class="header-cell">服务项目</text>
					<text class="header-cell">时间</text>
				</view>
				<view class="table-row" v-for="(item, index) in notifications" :key="index">
					<text class="table-cell">{{ item.user }}</text>
					<text class="table-cell">{{ item.service }}</text>
					<text class="table-cell">{{ item.time }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	components: {
		'custom-navbar': () => import('@/components/custom-navbar.vue')
	},
	data() {
		return {
			notifications: [
				{
					user: '张先生',
					service: '汽车美容、基础保养',
					time: '2022-03-10 11:09'
				},
				{
					user: '张先生',
					service: '汽车精细',
					time: '2022-03-10 11:09'
				},
				{
					user: '张先生',
					service: '车辆维修-上门取车',
					time: '2022-03-10 11:09'
				},
				{
					user: '张先生',
					service: '汽车美容、基础保养',
					time: '2022-03-10 11:09'
				},
				{
					user: '张先生',
					service: '车辆维修-到店维修',
					time: '2022-03-10 11:09'
				}
			]
		}
	},
	onLoad() {
		// 页面加载
	},
	methods: {
		// 跳转到扫码核销
		goToScan() {
			uni.navigateTo({
				url: '/pages/verification/scan'
			})
		},
		
		// 跳转到输入核销码
		goToInput() {
			uni.navigateTo({
				url: '/pages/verification/input'
			})
		},
		
		// 跳转到经营统计
		goToStatistics() {
			uni.navigateTo({
				url: '/pages/statistics/statistics'
			})
		},
		
		// 跳转到核销记录
		goToRecords() {
			uni.navigateTo({
				url: '/pages/records/records'
			})
		},
		
		// 跳转到收支明细
		goToFinance() {
			uni.navigateTo({
				url: '/pages/finance/finance'
			})
		},
		
		// 跳转到订单管理
		goToOrders() {
			uni.navigateTo({
				url: '/pages/orders/orders'
			})
		},
		
		// 跳转到卡券管理
		goToCoupons() {
			uni.navigateTo({
				url: '/pages/coupons/coupons'
			})
		},
		
		// 跳转到维修任务
		goToTasks() {
			uni.navigateTo({
				url: '/pages/tasks/tasks'
			})
		},
		
		// 跳转到评价管理
		goToReviews() {
			uni.navigateTo({
				url: '/pages/reviews/reviews'
			})
		},
		
		// 跳转到商户资料
		goToProfile() {
			uni.navigateTo({
				url: '/pages/profile/edit'
			})
		},
		
		// 跳转到活动发布
		goToActivities() {
			uni.navigateTo({
				url: '/pages/activities/activities'
			})
		},
		
		// 跳转到编辑资料页面
		goToEditProfile() {
			uni.navigateTo({
				url: '/pages/profile/edit'
			})
		},
		
		// 跳转到应急救援：跳转到抢单大厅
		goToRescue() {
			uni.navigateTo({
				url: '/pages/rescue/grab-hall'
			})
		},
	}
}
</script>

<style lang="scss" scoped>
.home-container {
	min-height: 100vh;
	background-color: #f5f5f5;
	padding-bottom: 120rpx;
	padding-top: calc(env(safe-area-inset-top) + 88rpx);
	position: relative;
	
	&::before {
		content: '';
		position: absolute;
		top: calc(env(safe-area-inset-top) + 88rpx);
		left: 0;
		right: 0;
		height: 600px;
		background-image: linear-gradient(
			to bottom,
			#2f81fa 0%, #2f81fa 33.33%,
			#f7f7f7 33.33%, #f7f7f7 100% 
		);
		background-repeat: no-repeat;
		z-index: 0;
	}
}

.header {
	background: transparent;
	padding: 20rpx 40rpx 20rpx;
	position: relative;
	z-index: 1;
	
	.header-content {
		display: flex;
		justify-content: space-between;
		align-items: center;
		
		.user-info {
			display: flex;
			align-items: center;
			
			.avatar {
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				overflow: hidden;
				margin-right: 24rpx;
				
				.avatar-img {
					width: 100%;
					height: 100%;
				}
			}
			
			.user-details {
				.shop-name {
					font-size: 32rpx;
					font-weight: 500;
					color: #ffffff;
					margin-bottom: 8rpx;
				}
				
				.shop-welcome {
					font-size: 28rpx;
					color: rgba(255, 255, 255, 0.9);
				}
			}
		}
		
		.header-actions {
			display: flex;
			gap: 20rpx;
			
			.action-btn {
				width: 60rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				
				.action-icon {
					font-size: 32rpx;
					color: #ffffff;
				}
			}
		}
	}
}

.verification-section {
	margin: 20rpx;
	position: relative;
	z-index: 1;
	
	.verification-buttons {
		background: #ffffff;
		border-radius: 16rpx;
		padding: 40rpx;
		display: flex;
		align-items: center;
		box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
		
		.verification-btn {
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			padding: 40rpx 20rpx;
			
			.btn-icon {
				width: 80rpx;
				height: 80rpx;
				margin-bottom: 20rpx;
			}
			
			.btn-text {
				font-size: 28rpx;
				color: #333333;
				font-weight: 500;
			}
		}
		
		.verification-divider {
			width: 2rpx;
			height: 150rpx;
			background-color: #e0e0e0;
			margin: 0 20rpx;
		}
	}
}

.menu-section {
	margin: 20rpx;
	position: relative;
	z-index: 1;
	
	.menu-grid {
		background: #ffffff;
		border-radius: 16rpx;
		padding: 40rpx;
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		gap: 40rpx;
		box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
		
		.menu-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			position: relative;
			
			.menu-icon {
				width: 80rpx;
				height: 80rpx;
				border-radius: 50%;
				margin-bottom: 16rpx;
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
				
				&.blue {
					background: #007AFF;
				}
				
				&.orange {
					background: #FF9500;
				}
				
				&.light-blue {
					background: #5AC8FA;
				}
				
				&.yellow {
					background: #FFCC00;
				}
				
				&.teal {
					background: #34C759;
				}
				
				&.red {
					background: #FF3B30;
				}
				
				.icon-img {
					width: 40rpx;
					height: 40rpx;
					filter: brightness(0) invert(1);
				}
				
				.badge {
					position: absolute;
					top: -8rpx;
					right: -8rpx;
					background: #FF3B30;
					color: #ffffff;
					font-size: 20rpx;
					min-width: 32rpx;
					height: 32rpx;
					border-radius: 16rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 0 8rpx;
				}
			}
			
			.menu-text {
				font-size: 24rpx;
				color: #333333;
				text-align: center;
				line-height: 1.2;
			}
		}
	}
}

.notification-section {
	margin: 20rpx;
	background: #ffffff;
	border-radius: 16rpx;
	overflow: hidden;
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
	position: relative;
	z-index: 1;
	
	.notification-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;
		margin: 0 15rpx;
		border-bottom: 1rpx solid #f0f0f0;
		
		.header-left {
			display: flex;
			align-items: center;
			
			
			.header-icon {
				width: 40rpx;
				height: 40rpx;
				margin-right: 16rpx;
			}
			
			.header-title {
				font-size: 26rpx;
				color: #333333;
				font-weight: 500;
			}
		}
		
		.header-right {
			.header-link {
				font-size: 22rpx;
				color: #FF9500;
			}
		}
	}
	
	.notification-table {
		.table-header {
			display: flex;
			padding: 24rpx 32rpx;
			background: #ffffff;
			border-bottom: 1rpx solid #f0f0f0;
			
			.header-cell {
				flex: 1;
				font-size: 27rpx;
				color: #363636;
				text-align: center;
				
				&:first-child {
					text-align: left;
				}
				
				&:last-child {
					text-align: right;
					margin-right: 50rpx;
				}
			}
		}
		
		.table-row {
			display: flex;
			padding: 24rpx 32rpx;
			border-bottom: 1rpx solid #f0f0f0;
			
			&:last-child {
				border-bottom: none;
			}
			
			.table-cell {
				flex: 1;
				font-size: 20rpx;
				color: #999999;
				text-align: center;
				
				&:first-child {
					text-align: left;
					margin-right: -20rpx;
				}
				
				&:last-child {
					margin-left: 30rpx;
					text-align: right;
					color: #999999;
					font-size: 20rpx;
				}
			}
		}
	}
}
</style>
